package com.fdd.furns.dao.impl;

import com.fdd.furns.dao.BasicDAO;
import com.fdd.furns.dao.MemberDAO;
import com.fdd.furns.pojo.Member;

public class MemberDAOImp extends BasicDAO implements MemberDAO {
    @Override
    public Member queryMemberByName(String name) {
        return (Member)querySingle("select * from member where name = ?", Member.class, name);
    }

    @Override
    public int saveMember(Member member) {
        String sql = "INSERT INTO member(`username`,`password`,`email`) \n" +
                "VALUES(?,MD5(?),?); ";
        return update(sql, member.getName(), member.getPassword(), member.getEmail());
    }

    @Override
    public Member queryMemberByNameAndPwd(String name, String password) {
        String sql = "select * from member where name = ? and password = MD5(?)";
        return (Member)querySingle(sql, Member.class, name, password);
    }
}
